package cn.wizzer.util;

import cn.wizzer.framework.util.ScriptUtil;
import org.nutz.log.Log;
import org.nutz.log.Logs;

public class VideoUtil {

    private static final Log log = Logs.get();


    public static boolean fetchFrame(String streamUrl, String imgPath) {
        return ScriptUtil.execute("ffmpeg -i \"" + streamUrl + "\" -f image2 -ss 0 -vframes 1 -s 390*220 -y \"" + imgPath + "\"");
    }
    public static boolean mp4ToM3u8(String filePath) {
        ScriptUtil.execute("mkdir -p " + filePath);
        return ScriptUtil.execute("ffmpeg -i " + filePath + ".mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls " + filePath + "/index.m3u8");
    }
}
